﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Module.Core.BusinessLogic.CmsContents;
using Module.Core.Common;

namespace Web
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadMenuTop();
        }

        void  LoadMenuTop()
        {
            ltMenu.Text = "";
            DataTable dt=new DataTable();
            dt = CMSZonesBL.GetMenu(ClsCheckBox.menuLeft, 0, 0, "");
            if(dt !=null && dt.Rows.Count > 0)
            {               
                ltMenu.Text = "<ul>";
                foreach (DataRow dr in dt.Rows)
                {               
                    ltMenu.Text += "<li><a href=\"#\">" + dr["Title"] + "</a>";
                    ltMenu.Text += SubItemMenu(int.Parse(dr["zoneId"].ToString()));
                    ltMenu.Text += "</li>";                  
                }
                ltMenu.Text += "</ul>";
            }
        }

        string SubItemMenu(int zoneId)
        {
            string html = string.Empty;
            DataTable dt = new DataTable();
            dt = CMSZonesBL.GetMenu(0, zoneId, 0, "");
            if (dt != null && dt.Rows.Count > 0)
            {               
                html = "<ul>";
                foreach (DataRow dr in dt.Rows)
                {                   
                    html += "<li><a href=\"#\">" + dr["Title"] + "</a></li>";
                }
                html += "</ul>";
            }
            return html;
        }
    }
}